package controller

import (
	"github.com/gin-gonic/gin"
	"my-go-gateway/dto"
	"my-go-gateway/middleware"
	"my-go-gateway/services"
)

type AdminController struct {
}

func AdminRegister(group *gin.RouterGroup) {
	admin := &AdminController{}
	group.POST("/change_pwd", admin.ChangePwd)
}

// ChangePwd godoc
// @Summary 修改密码
// @Description 修改密码
// @Tags 管理员接口
// @ID /admin/change_pwd
// @Accept  json
// @Produce  json
// @Param body body dto.ChangePwdInput true "body"
// @Success 200 {object} middleware.Response{data=string} "success"
// @Router /admin/change_pwd [post]
func (a *AdminController) ChangePwd(c *gin.Context) {

	params := &dto.ChangePwdInput{}
	if err := params.BindValidParam(c); err != nil {
		middleware.ResponseError(c, 2000, err)
		return
	}

	adminService := &services.AdminService{}
	err, erCode := adminService.ChangePwd(c, params)
	if err != nil {
		middleware.ResponseError(c, erCode, err)
		return
	}
	middleware.ResponseSuccess(c, "")
}
